<?php

namespace App\Listeners;

use App\Events\OperationLogEvent;
use App\Models\AdminOperationLog;

class OperationLogListener extends ListenerQueue
{
    public $queue = 'log';


    public function tags()
    {
        return ['admin_operation'];
    }
    /**
     * Handle the event.
     *
     * @param object $event
     * @return void
     */
    public function handle(OperationLogEvent $event)
    {
        $data = $event->data;

        try {
            AdminOperationLog::query()->create($data);
            return;
        } catch (\Exception $e) {
            info($e->getMessage(), ['method' => __METHOD__, 'file' => $e->getFile(), 'line' => $e->getLine()]);
        }
    }
}
